package com.yurui.controller;


import com.yurui.entities.CommonResult;
import com.yurui.entity.Storage;
import com.yurui.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("storage")
public class StorageController {


    private final StorageService storageService;

    public StorageController(StorageService storageService) {
        this.storageService = storageService;
    }


    @PostMapping("decrease")
    public CommonResult<String> decrease(Long productId, Integer count) {
        log.info("调用库存的接口,productId=" + productId);
        storageService.decrease(productId, count);
        return new CommonResult<>("减库存成功");
    }

}
